<!--
 * @Description:
 * @Author: william
 * @Date: 2025-02-17 16:47:40
 * @LastEditors: william
 * @LastEditTime: 2025-07-22 19:30:16
-->
<template>
  <BaseDialog
    v-model="dialogVisible"
    :title="$t('public.detail')"
    width="850px"
    :before-close="handleClose"
  >
    <el-descriptions
      v-loading="viewLoading"
      :column="2"
      border
      :label-width="120"
    >
      <el-descriptions-item width="200">
        <template #label>{{ $t('fleet.customerName') }}</template>
        {{ formData.customerName || '--' }}
      </el-descriptions-item>
      <el-descriptions-item width="200">
        <template #label>{{ $t('fleet.customerContact') }}</template>
        {{ formData.customerContact || '--' }}
      </el-descriptions-item>
      <el-descriptions-item width="200">
        <template #label>{{ $t('fleet.contactPhone') }}</template>
        {{ formData.customerContactPhone }}
      </el-descriptions-item>
      <el-descriptions-item width="200">
        <template #label>{{ $t('fleet.customerEmail') }}</template>
        {{ formData.customerContactEmail }}
      </el-descriptions-item>
      <el-descriptions-item width="200">
        <template #label>{{ $t('fleet.emergencyContact') }}</template>
        {{ formData.customerEmergencyContact || '--' }}
      </el-descriptions-item>
      <el-descriptions-item width="200">
        <template #label>{{ $t('fleet.emergencyContactPhone') }}</template>
        {{ formData.customerEmergencyContactPhone || '--' }}
      </el-descriptions-item>
      <!-- <el-descriptions-item width="200">
        <template #label>{{ $t('public.remark') }}</template>
        {{ formData.note || '--' }}
      </el-descriptions-item> -->
    </el-descriptions>
    <template #footer>
      <div class="detail-dialog-footer">
        <el-button plain @click="handleClose">{{
          $t('public.close')
        }}</el-button>
      </div>
    </template>
  </BaseDialog>
</template>

<script setup>
const props = defineProps({
  id: {
    type: String,
    default: ''
  }
})

const dialogVisible = defineModel({
  type: Boolean,
  default: false
})
const viewLoading = ref(false)
const formData = ref({})

onMounted(() => {
  getFormData()
})

const getFormData = () => {
  viewLoading.value = true
  g_api.customer
    .apiCustomerQueryDetail({ id: props.id })
    .then(({ code, data }) => {
      if (code === '200' && data) {
        formData.value = data
      }
    })
    .finally(_ => {
      viewLoading.value = false
    })
}

const handleClose = () => {
  dialogVisible.value = false
}
</script>

<style scoped lang="scss"></style>
